package com.qf.service;

import com.qf.dao.UserDao;
import com.qf.pojo.User;

import java.io.FileNotFoundException;
import java.util.List;

/**
 * 类  ；图纸
 *
 * @author lixu
 */
public class UserServiceImpl implements UserService {
    //声明  引用注入
    private UserDao userDao;
    private OrderService orderService;
    private OrderDetailService orderDetailService;

    // 添加订单表  订单详情表
    public void insertOrder() {
        //开启事务
        orderService.insertOrder();

        int i = 1/0;

        orderDetailService.insertOrderDetail();

        //commit

    }






    public void setOrderService(OrderService orderService) {
        this.orderService = orderService;
    }

    public void setOrderDetailService(OrderDetailService orderDetailService) {
        this.orderDetailService = orderDetailService;
    }


    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public List<User> findUser() {
        return userDao.findUser();
    }


    //修改
    public void update(User user) throws FileNotFoundException {

        userDao.insert(user);

   /*     if(null==null){
            throw  new FileNotFoundException();
        }*/
        int i = 1/0; //算法异常 ArithmeticException  是RuntimeException 子类
   /*     try {
            Thread.sleep(6000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }*/

        userDao.update(user);

    }

}
